#include <stdlib.h>
#include <stdio.h>
#include <nds.h>

// common headers
#include "common.h"

// local headers
#include "jpg.h"

#include "main.h"

#define _VERSION_INT MAKE_VERSION(0, 0, 1, STATE_ALPHA, 1)
char _VERSION_STR[VERSION_STR_MAX_LEN+1];

char *_exts[] = { ".jpg", ".jpeg" };
sEL exts={
	.exts=_exts,
	.extnum=sizeof(_exts)/sizeof(*_exts)
};

// picture interface
sPInterface sPI = {
	.decode=decode,
	.encode=encode
};

int init() {
	std->sprintf(_VERSION_STR, VERSION_FORMAT, VERSION_ARGS(_VERSION_INT));	// make version str

	return 0;
}

u32 query(u32 query) {
	switch(query) {
	case QUERY_NAME:		// library name
		return (u32)"libjpg";
	case QUERY_VERSION_INT:	// library integer version
		return (u32)_VERSION_INT;
	case QUERY_VERSION_STR:	// library string version
		return (u32)_VERSION_STR;
	case QUERY_AUTHOR:		// library author
		return (u32)"Ludo6431";
	case QUERY_FILEEXT:		// file extensions
		return (u32)&exts;
	case QUERY_ID:			// library identifier
		return ID_LIBRARY_PICTURE;
	case QUERY_FSTRUCT:		// library author
		return (u32)&sPI;	// returns the picture interface structure
	default:
		return 0;
	}
}

void deinit() {
}

